struct Material {
  vec3 aColor;
  vec3 dColor;
  vec3 sColor;
  float shine;
};

varying vec3 nLightPos;
varying vec3 nNormal;
varying vec4 midNormal;
varying vec4 r;
varying vec3 rcheating;
varying float angle;
attribute vec3 aPosition;
attribute vec3 aNormal;

uniform mat4 uProjMatrix;
uniform mat4 uViewMatrix;
uniform mat4 uModelMatrix;
uniform vec3 ePosition;
uniform vec3 uLightPos;
uniform vec3 uLColor;
uniform Material uMat;

varying vec3 vColor;
void main() {
  vec4 ePosn;
  vec4 vPosition;
  vec4 light;

  /* First model transforms */
  vPosition = uModelMatrix* vec4(aPosition.x, aPosition.y, aPosition.z, 1);
  ePosn = vec4(ePosition.x, ePosition.y, ePosition.z, 1);

  nLightPos = normalize(uLightPos);
  nNormal = normalize(aNormal);
  angle = dot(nLightPos, nNormal);
  if(angle < 0.0) {
    angle = 0.0;
  }

  rcheating = -1.0 * nLightPos + 2.0 * angle * nNormal;
  r = vec4(rcheating.x, rcheating.y, rcheating.z, 1);
  r = normalize(r);

  vPosition = uViewMatrix* vPosition;
  gl_Position = uProjMatrix*vPosition;
  /* TO DO REPLACE THIS WITH lighting!!!! */
  /* vColor = vec3(0.5, 0.5, 0.5); */

  //vColor = aNormal;
  vColor = (uLColor * angle * uMat.dColor) + (uLColor * dot(r, ePosn) * uMat.sColor)  + (uMat.aColor * uLColor);
}
